import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ProductGroupVO, ProductGroupForm, ProductGroupQuery } from '@/api/productGroup/types';

/**
 * 查询产品分组列表
 * @param query
 * @returns {*}
 */

export const listProductGroup = (query?: ProductGroupQuery): AxiosPromise<ProductGroupVO[]> => {
  return request({
    url: '/company/productGroup/myList',
    method: 'get',
    params: query
  });
};

/**
 * 查询产品分组详细
 * @param id
 */
export const getProductGroup = (id: string | number): AxiosPromise<ProductGroupVO> => {
  return request({
    url: '/company/productGroup/' + id,
    method: 'get'
  });
};

/**
 * 新增产品分组
 * @param data
 */
export const addProductGroup = (data: ProductGroupForm) => {
  return request({
    url: '/company/productGroup',
    method: 'post',
    data: data
  });
};

/**
 * 修改产品分组
 * @param data
 */
export const updateProductGroup = (data: ProductGroupForm) => {
  return request({
    url: '/company/productGroup',
    method: 'put',
    data: data
  });
};

/**
 * 删除产品分组
 * @param id
 */
export const delProductGroup = (id: string | number | Array<string | number>) => {
  return request({
    url: '/company/productGroup/' + id,
    method: 'delete'
  });
};
